package Ep02_LinkedList._0067;

/**
 * @author Jimmy Zhan WORKSTATION
 * @date 2023/3/8 21:02
 * 说明： 力扣 0067二进制转 10进制
 */

public class Mine {
    public String addBinary(String a, String b) {
        int ia = Integer.parseInt(a);
        int ib = Integer.parseInt(b);

        int sum = BinaryToInt(ia) + BinaryToInt(ib);
        String resString = Integer.toBinaryString(sum);

        return resString;
    }

    public int BinaryToInt(int n){
        int n_pow = 0;
        int res = 0;
        while(n != 0){
            res += (n % 10) * (int)Math.pow(2,n_pow);
            n /= 10;
            n_pow++;
        }
        return res;
    }
}
